package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.ZujiBean;
import com.lwj.liwanjia.impl.ZujiView;
import com.lwj.liwanjia.model.ZujiModel;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/12/4.
 */

public class ZujiPresenter {
    private ZujiView zujiView;
    private ZujiModel zujiModel;

    public ZujiPresenter(ZujiView zujiView) {
        this.zujiView = zujiView;
        zujiModel = new ZujiModel();
    }

    public void getZuji(String token) {
        if (zujiView != null) {
            zujiModel.getZuji(token, new Subscriber<ZujiBean>() {
                @Override
                public void onCompleted() {
                    zujiView.hideProgress();
                }

                @Override
                public void onError(Throwable e) {
                    zujiView.showError((Exception) e);
                    zujiView.hideProgress();
                }

                @Override
                public void onNext(ZujiBean zujiBean) {
                    zujiView.getZuji(zujiBean);
                }

                @Override
                public void onStart() {
                    super.onStart();
                    zujiView.showProgress();
                }
            });
        }
    }
}
